let mysqlpool = require("../../model/connect");
const changeChargeStationControler=async (request,response)=>{
    let {charge_id,charge_station_status} = request.query;
    // console.log(charge_id,charge_station_status);
    let use = null;
    sql_check = `select charge_station_use from charge_station_info WHERE charge_id = ${charge_id}`
    await mysqlpool.query(sql_check, async (err,res)=>{
        use = res[0].charge_station_use
        //取出表单charge_station和charge_station_info信息
        let sql_change = `UPDATE charge_station_info SET charge_station_status = '${charge_station_status}',charge_station_use = '${use+1}' WHERE charge_id = '${charge_id}'`
        await mysqlpool.query(sql_change, (err,res)=>{
            if(res.affectedRows) response.send("ok")
            else response.send("更改失败")
         })
    })
    
}
module.exports=changeChargeStationControler